/* file name  : Continuation.java
 * created    : Fri 23 Sep 2005 05:40:28 AM EDT
 * authors    : Saikat Guha <saikat@cs.cornell.edu>
 * copyright  : GNU Lesser General Public License version 2.1 or later
 * 
 * Copyright (C) 2005 Saikat Guha <saikat@cs.cornell.edu>
 * 
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA
 * 
 */
package net.nutss;

/**
 * Represents a continuation for an event-driven state machine
 *
 * @author Saikat Guha
 * @version %I%, %G%
 */
public interface Continuation {

    /**
     * Steps the continuation by one step.
     * @param o Event causing continuation step. null for timeout.
     * @param d Dispatch
     * @return timeout for current stage in milliseconds
     */
    int step(Object o, Dispatch d,STUNTSelector sel);

    /**
     * Initializes the continuation.
     *
     * @param arg Signaling message the continuation is generated in response to. May be null.
     * @return Signaling message to match future messages of interest
     */
    SignalingMessage init(SignalingMessage arg);

    /**
     * Cancels the continuation. Continuation will never be called again.
     *
     * @param d Dispatch
     */
    void cancel(Dispatch d);

}
